#! /usr/bin/env python
# -*- coding: UTF-8 -*-


import sys, re, urllib2

class Queue:
    """a simple queue implementation"""
    def __init__(self):
        self.list = []

    def __str__(self):
        return str(self.list)

    def enQ(self, X):
        self.list.append(X)

    def deQ(self):
        return self.list.pop(0)

    def size(self):
        return len(self.list)


class picParser:
    """
    HTML text parser

    There are two phase while downloading all pictures from the web
    first phase, search the thumb index page to get 
    all the picture pages which content the target pictures.
    second phase, download the target pictures from the picture pages.

    using pagesQ and pictsQ
    """
    def __init__(self, url=""):
        self.url = url
        self.pagesQ = Queue()
        self.pictsQ = Queue()


    def action(self):
        if self.url:
            self.pagesQ.enQ("pages")
            self.pictsQ.enQ("pictures")
            print(self.pagesQ)
            print(self.pictsQ)
            print(self.pagesQ.size())
            print(self.pictsQ.size())
            self.pagesQ.deQ()
            self.pictsQ.deQ()


if __name__ == "__main__":
    picParser().action()
    picParser("test").action()

